/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.xinxi.dms.service;

import com.xinxi.dms.dao.StudentDao;
import com.xinxi.dms.po.Student;
import java.util.List;

/**
 *
 * @author zhigu
 */
public class StudentServiceIMPL implements IStudentService{
    StudentDao studentDao = new StudentDao();
    @Override
    public boolean into(Student student) {
        String sql ="insert into student(stuname,stusex,stuage,stuschool,stuphone,stucard,buildingno,unitno,roomno,state) values(?,?,?,?,?,?,?,?,?,?)";
        Object[] params ={student.getStuname(),student.getStusex(),student.getStuage(),student.getStuschool(),student.getStuphone(),student.getStucard(),student.getBuildingno(),student.getUnitno(),student.getRoomno(),student.getState()};
        return studentDao.update(sql, params);
    }
    @Override
    public List<Student> findAll() {
        String sql = "select * from student";
        Object[] params={};
        return studentDao.query(sql, Student.class, params);
    }

    @Override
    public boolean update(Student student) {
        String sql = "update student set stuname= ?,stusex = ? , stuage = ? , stuschool = ? , stuphone = ? , stucard = ? , buildingno = ? , unitno = ? , roomno = ? where stuid =?";
        Object[] params = {student.getStuname(),student.getStusex(),student.getStuage(),student.getStuschool(),student.getStuphone(),student.getStucard(),student.getBuildingno(),student.getUnitno(),student.getRoomno(),student.getStuid()};
        return studentDao.update(sql, params);
    }

    @Override
    public boolean delete(Integer stuid) {
        String sql = "delete from student where stuid = ?";
        Object[] params={stuid};
        return studentDao.update(sql, params);
    }
    
}
